package io.github.lee.jel.manager


import android.util.Log
import io.github.lee.jel.domain.po.JellyfinSession
import io.github.lee.jel.global.di.http.HttpModule


object JellyfinSessionManager {
    private val watcherList = mutableListOf<JellyfinSessionWatcher>()


    fun postSession(session: JellyfinSession) {
        HttpModule.resetNetwork(session)
        watcherList.forEach {
            it.onSessionChange(session)
        }
    }

    fun postSessionDelete(session: JellyfinSession?) {
        watcherList.forEach {
            it.onSessionDelete(session)
        }
    }

    fun registerWatcher(watcher: JellyfinSessionWatcher) {
        if (!watcherList.contains(watcher)) {
            watcherList.add(watcher)
        }
    }

    fun unregisterWatcher(watcher: JellyfinSessionWatcher) {
        watcherList.remove(watcher)
    }


}